#ifndef __LIB_AGORA_CLIENT_EVENTMANAGER_H__
#define __LIB_AGORA_CLIENT_EVENTMANAGER_H__

#include <list>
#include <map>
#include <string>
#include "IChannel.h"
#include "IUser.h"
#include "IChannelRight.h"
#include "IHostRight.h"

namespace AgoraClient
{

class AdminEventManager
{
public:
	static AdminEventManager* GetAdminEventManager();

	// TODO heritage sur les EventArg, specialisation
	struct EventArg
	{
		std::list<IChannel *> ChannelList;
		std::list<IUser *> UserList;
		std::map<unsigned int, IChannelRight*> ChannelRights;
		IHostRight*	UserHostRight;
		IChannel*	ChannelFrom;
		IChannel*	ChannelTo;
		std::string	Message;
		unsigned int ErrorCode;
	};

	enum EventName
	{
		ONCHANNELLISTRECEIVED,
		ONUSERLISTRECEIVED,
		ONCHANNELCREATED,
		ONCHANNELEDITED,
		ONCHANNELDELETED,
		ONUSERDELETED,
		ONUSERCREATION,
		ONUSERCONNECTION,
		ONUSERCHANNELCHANGE,
		ONUSERDISCONNECTION,
		ONERROR,
		ONHOSTRIGHTRECEIVED,
		ONCHANNELRIGHTRECEIVED,
		ONUSERHOSTRIGHTRECEIVED,
		ONUSERCHANNELRIGHTRECEIVED,
		ONUSERHOSTRIGHTEDITED,
		ONUSERCHANNELRIGHTEDITED,
		ONUSERKICKED,
		ONUSERKICKEDFROMSERVER,
		ONUSERBANNED,
		ONUSERBANNEDFROMSERVER,
		ONUSERBANNEDLISTRECEIVED,
		ONUSERBANNEDFROMSERVERLISTRECEIVED,
		ONUSERUNBANNED,
		ONUSERUNBANNEDFROMSERVER,
		ONUSERMESSAGERECEIVED,
		ONCHANNELMESSAGERECEIVED,
		ONALLCHANNELMESSAGERECEIVED,
		ONUSERMUTESOUNDCHANNEL,
		ONUSERMUTETXTCHANNEL,
		ONUSERUNMUTESOUNDCHANNEL,
		ONUSERUNMUTETXTCHANNEL
	};

	typedef void (*Callback)(EventArg *e, void *data);

	void	SubscribeOnEvent(EventName name, Callback fct, void* data);
	
	void	LaunchEvent(EventName name, EventArg *e);

private:
	struct	CallbackInfo
	{
		Callback	Function;
		void*		Data;
	};
	AdminEventManager();
	static AdminEventManager *_instance;
	std::map<EventName, CallbackInfo> _callbacks;
	
};

}
#endif